package receivers;

import com.rabbitmq.client.Connection;
import utils.Mode;

import java.io.IOException;

public class ReceiverFactory {
    public static Receiver getReceiver(Mode mode, Connection connection, String queueName, String exchangeName, String routingKey) throws IOException {
        switch (mode){
            case SIMPLE:
            case WORK_QUEUE:
                return new SimpleReceiver(connection, queueName, true, "", "", "");
            case DIRECT:
            case ROUTING:
                return new ExchangeReceiver(connection, queueName, true, exchangeName, "direct", routingKey);
            case PUBLISH_SUBSCRIBER:
                return new ExchangeReceiver(connection, queueName, true, exchangeName, "fanout", "");
            case TOPIC:
                return new ExchangeReceiver(connection, queueName, true, exchangeName, "topic", routingKey);
        }
        return null;
    }
}
